package demoMod.stsconsole.helpers;

import demoMod.stsconsole.characters.AbstractPlayer;
import demoMod.stsconsole.characters.IronClad;
import demoMod.stsconsole.dungeons.AbstractDungeon;

import java.util.ArrayList;
import java.util.List;

public class CharacterManager {
    private static List<Class<? extends AbstractPlayer>> playerCls;
    private static List<AbstractPlayer> players;

    public static void initialize() {
        playerCls = new ArrayList<>();
        playerCls.add(IronClad.class);

        players = new ArrayList<>();
        players.add(new IronClad());
    }

    public static boolean createCharacter(int index) {
        try {
            if (AbstractDungeon.player != null) AbstractDungeon.player.onRemove();
            AbstractDungeon.player = playerCls.get(index).newInstance();
            return true;
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
            return false;
        }
    }

    public static List<AbstractPlayer> getAllPlayers() {
        return new ArrayList<>(players);
    }
}
